package logic

import (
	"context"

	"goods/goods"
	"goods/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type GetGoodsSkuByIdLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGetGoodsSkuByIdLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetGoodsSkuByIdLogic {
	return &GetGoodsSkuByIdLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *GetGoodsSkuByIdLogic) ExistGoodsSkuById(in *goods.GetGoodsSkuByIdRequest) (*goods.GetGoodsSkuByIdResponse, error) {
	// todo: add your logic here and delete this line
	res, err := l.svcCtx.GoodsSku.ExistGoodsSku(context.Background(), int64(in.Id))
	if err != nil {
		return &goods.GetGoodsSkuByIdResponse{Code: -1, Msg: "获取商品规格失败"}, err
	}

	return &goods.GetGoodsSkuByIdResponse{Code: 200, Msg: "获取成功", Data: res}, nil

}
